﻿using System;
using System.Threading;
using YanZhiwei.DotNet3._5.Utilities.Base;
using YanZhiwei.DotNet3._5.Utilities.Base.SchedulerType;
namespace YanZhiwei.DotNet3._5.Utilities.Examples
{
    public class TaskExamle
    {
        public static void Demo1()
        {
            try
            {
                ScheduleExecutionOnce _schedule = new ScheduleExecutionOnce();
                _schedule.ExecutionTime = DateTime.Now.AddMinutes(1);
                Task tk = new Task((obj) =>
                {
                    Console.WriteLine("任务完成" + obj);

                }, _schedule);
                tk.GroupName = "YanZhiwei";
                tk.Start("YanZhiwei");
                while (TaskScheduler.Count > 0)
                {
                    Thread.Sleep(1000);
                    TimeSpan _ts=TaskScheduler.GroupTaskDueTime("YanZhiwei");
                    Console.WriteLine("当前任务数量：" + TaskScheduler.Count + " 该组任务还需要" +_ts.Minutes+"分钟"+ _ts.Seconds+"秒");
                }
            }
            finally
            {
                // Console.WriteLine("当前任务数量：" + TaskScheduler.Count);
            }
        }
    }
}
